// pages/load/load.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var spid = options.spid
    var bgc = wx.getStorageSync('color')
    var gsname = options.gsname
    var orders = options.orders
    var shname = options.shname
    var spid = options.spid
    var com = options.com
    var num = options.num
    var orderstatus = options.orderstatus
    var id = options.id
    //gsname=申通&orderss=14833566621594130768&id=1&com=shentong&num=773042203466575


    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    app.util.request({
      'url': 'entry/wxapp/index.kuaidiselect',
      data: {
        spid: spid,
        com: com,
        num: num
      },
      header: {
        'Content-Type': 'application/json'
      },
      success: function (res) {
        var list = res.data.data;
        if (res.data.returnCode == '500') {
          that.setData({
            list: [],
            type: 0
          })
        } else {
          list.map(function (val, index) {
            val.id = index;
          });
          that.setData({
            list: list,
            type: 1
          })
        }

      }
    })
    that.setData({
      gsname: gsname,
      orders: orders,
      shname: shname,
      spid: spid,
      id: id,
      orderstatus: orderstatus,
      num:num
    })
    this.getGoodsdetail()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  getGoodsdetail() {
    var that = this
    var sid = that.data.id
    app.util.request({
      'url': 'entry/wxapp/goods.detail',
      data: {
        sid: sid
      },
      success: function (res) {
        console.log(res)
      }
    })
  }
})